package com.edu.demo.mapper;

import com.edu.demo.entity.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author jixuewei
 * @since 2023-01-12
 */
@Mapper
public interface RoleMapper extends BaseMapper<Role> {

    @Select("select r.* from user_role ur,role r where ur.role_id=r.id and ur.type = #{type} and ur.user_id = #{uId}")
    Role selectRoleByUserIdAndType(@Param("type") String tpe,@Param("uId") Integer userId);

    @Insert("insert into role_menu values(#{rId},#{mId})")
    int insertRoleMenu(@Param("rId") Integer rid,@Param("mId") Integer mid);
}
